﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestConsole
{
    public static class UniqueRandNum
    {
        private static HashSet<double> generatedNumbersSet = new HashSet<double>();
        private static Random randomNumber = new Random();

        public static float GetUniqueNumber(double max, double min)
        {
            double rnd = 0;

            if (!generatedNumbersSet.Contains(0)) generatedNumbersSet.Add(0);

            while (generatedNumbersSet.Contains(rnd))
            {
                rnd = randomNumber.NextDouble() * (max - min);
                rnd += min;
            }

            generatedNumbersSet.Add(rnd);
            return (float)rnd;
        }
    }
}
